{[{ define "admin/admin.html" }]}
<!DOCTYPE html>
<html lang="en">
<head>
    {[{template "admin/headerbody" .}]}
</head>
<body>
<div>

    {[{template "admin/header" .}]}

    <div id="app" class="container grid-lg indexcontent">

        <div class="columns">
            <div class="column col-3  col-md-3">{[{template "admin/menu" .}]}</div>
            <div class="column col-9 col-md-9 col-sm-12  col-xs-12">

                <form>

                    <div class="form-group">
                        <label class="form-label" for="input-name">博客名称</label>
                        <input class="form-input" type="text" id="input-name" v-model="seting.blogname">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-blogtitle">副标题</label>
                        <input class="form-input" type="text" id="input-blogtitle" v-model="seting.blogtitle">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-author">默认作者</label>
                        <input class="form-input" type="text" id="input-author" v-model="seting.author">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-beian">网站备案号</label>
                        <input class="form-input" type="text" id="input-beian" v-model="seting.beian">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-keywords">网站关键词</label>
                        <input class="form-input" type="text" id="input-keywords" v-model="seting.keywords">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-description">网站描述</label>
                        <input class="form-input" type="text" id="input-description" v-model="seting.description">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-github">Github</label>
                        <input class="form-input" type="text" id="input-github" v-model="seting.github">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-commentcode">评论配置: appid|conf
                            例:cyuIOoDgG|prod_c067658bcd27bed4c257adddca501157 <a href="https://changyan.kuaizhan.com/"
                                                                                 target="_blank">申请</a></label>
                        <input class="form-input" type="text" id="input-commentcode" v-model="seting.commentcode">
                    </div>

                    <div class="form-group">
                        <label class="form-label" for="input-counter">计数器</label>
                        <textarea class="form-input" id="input-counter" rows="5" v-model="seting.counter"></textarea>
                        用于存放百度,CNZZ等计数器脚本
                    </div>

                    <div class="form-group">
                        <input type="button" value="保存" class="btn btn-primary" @click="Save()">
                    </div>

                    <div class="form-group">
                        <span class="label label-error" v-if="errormsg.length>0">{{errormsg}}</span>
                    </div>

                    <div class="form-group">
                        <span class="label label-success" v-if="message.length>0">{{message}}</span>
                    </div>
                </form>

            </div>

        </div>
    </div>


    {[{template "admin/footer" .}]}
</div>

<script>
    // 创建 Vue 实例，得到 ViewModel
    var vm = new Vue({
        el: '#app',
        data() {
            return {
                seting: {
                    systemid: 0,
                    blogname: "",
                    github: "",
                    counter: "",
                    author: "",
                    beian: "",
                    description: "",
                    keywords: "",
                    blogtitle: "",
                    commentcode: ""
                },
                errormsg: "",
                message: ""
            }
        },
        mounted() {
            this.GetInfo();
        },
        methods: {
            //获取验证码
            GetInfo: function () {
                var that = this;
                //发送get请求
                axios.get('../api/v1/blogsetting').then(function (res) {
                    if (res.data) {
                        if (res.data.status == 200) {
                            that.seting = res.data.data;
                        } else {
                            that.errormsg = res.data.message;
                        }
                    }

                }).catch(function (error) {
                    console.log(error);
                });

            },
            //保存
            Save: function () {
                this.errormsg = "";
                var that = this;

                if (this.seting.blogname == "") {
                    this.errormsg = "请填写博客名称";
                    return;
                }
                //发送get请求
                axios.post('../api/v1/blogsetting', this.seting).then(function (res) {
                    if (res.data) {
                        if (res.data.status == 200) {
                            that.message = res.data.message;
                        } else {
                            that.errormsg = res.data.message;
                        }
                    }

                }).catch(function (error) {
                    console.log(error);
                });

            }
        }
    });
</script>
</body>
</html>

{[{end}]}